home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / wdj0797.zip / NELSON.ZIP / JUL97.CPP
C/C++ Source or Header  |  1997-04-10  |  2KB  |  65 lines

  1. -------------------------------Listing 1------------------------------------
  2. //
  3. // JUL97.CPP
  4. //
  5. // This program demonstrates a problem in Borland's
  6. // puttext() routine in the 5.01 release of their
  7. // C++ compiler.  For some reason, the library refuses
  8. // to execute legal calls to puttext() that write to
  9. // the last two columns of the screen in text mode.
  10. //
  11. // Compile this program using the following command:
  12. //
  13. //  BCC Jul97.cpp
  14. //
  15. //  When run, it displays two identical sections
  16. //  of text.  The first prints lines of 73 through 80
  17. //  characters using printf.  The second section does
  18. //  the same using puttext().
  19. //
  20. //  Recompile using this line:
  21. //
  22. //  BCC32 Jul97.cpp
  23. //
  24. //  Now the puttext() section will be missing two lines,
  25. //  the ones of length 79 and 80.
  26. //
  27. #include <stdio.h>
  28. #include <conio.h>
  29.  
  30.  
  31. main()
  32. {
  33.    char put_buf[ 80 * 2 ];
  34.    char printf_buf[ 81 ];
  35.    for ( int i = 0 ; i < 80 ; i++ ) {
  36.         put_buf[ i*2 ] = "0123456789"[ i % 10 ];
  37.         put_buf[ i*2 + 1 ] = 7;
  38.         printf_buf[ i ] = "0123456789"[ i % 10 ];
  39.    }
  40.    printf_buf[ 80 ] = '\0';
  41.    clrscr();
  42.    //
  43.    // print lines of length 80 down to 73 chars using printf()
  44.    //
  45.    gotoxy( 1, 1 );
  46.    printf( "printf() output:" );
  47.    for ( int i = 0 ; i < 8 ; i++ ) {
  48.         gotoxy( 1, 3 + i );
  49.         printf( printf_buf );
  50.         printf_buf[ 79 - i ] = '\0';
  51.     }
  52.    //
  53.    // print lines of length 80 down to 73 chars using puttext()
  54.    //
  55.     gotoxy( 1, 12 );
  56.     printf( "puttext() output:" );
  57.     for ( int i = 0 ; i < 8 ; i++ )
  58.        puttext( 1, i + 14, 80 - i, i + 14, put_buf );
  59.     gotoxy( 1, 23 );
  60.     return 0;
  61. }
  62.  
  63.  
  64.  
  65.